package aidturith.ihm.component;

import java.awt.Image;
import java.awt.Toolkit;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import aidturith.Constant;

public class ButtonImage extends JButton {

	private static final long serialVersionUID = 1L;

	public ButtonImage(String icon) throws IOException {
		super();
		if(Constant.DEBUG) System.out.println(Constant.ICONS_LOCAL+icon);
		//Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource(Constant.ICONS_JAR+icon));
		Image img = Toolkit.getDefaultToolkit().createImage(Constant.ICONS_LOCAL+icon);
		setIcon(new ImageIcon(img));
		setBorder(BorderFactory.createEmptyBorder());
		setContentAreaFilled(false);
	}

	public void setIcon(String icon) {
		//Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource(Constant.ICONS_JAR+icon));
		Image img = Toolkit.getDefaultToolkit().createImage(Constant.ICONS_LOCAL+icon);
		super.setIcon(new ImageIcon(img));
	}

}
